
cc.Class({
    extends: cc.Component,

    properties: {

    },

    // LIFE-CYCLE CALLBACKS:
    ctor(){
        this._gongIdx = -1;
    },

    onLoad () {
        this.board = [];
        for(let i = 0; i < 3; ++i){
            this.board[i] = [];
            for(let j = 0; j < 3;++j){
                let nd_cell = cc.instantiate(G.pfRes.pf_cell);
                nd_cell.setParent(this.node);
                nd_cell.x = 5 + G.kCellSize * j + G.kCellSize/2;
                nd_cell.y = 5 + G.kCellSize * (2 - i) + G.kCellSize/2;
                let cell = nd_cell.getComponent('cell');
                this.board[i][j] = cell;
            }
        }
    },

    setGongIdx(gongIdx){
        this._gongIdx = gongIdx;
    },

    getGongIdx(){
        return this._gongIdx;
    },


    getGongRowCells(idx){
        return this.board[idx];
    },

    getGongRowValues(idx){
        let cells = this.getGongRowCells(idx);
        return cells.map(cell=>{
            return cell.getValue();
        });
    },

    getGongColumnCells(idx){
        let cells = [];
        for(let r = 0; r < this.board.length; ++r){
            cells.push(this.board[r][idx]);
        }
        return cells;
    },

    getGongColumnValues(idx){
        let cells = this.getGongColumnCells(idx);
        return cells.map(cell=>{
            return cell.getValue();
        });
    }

    // start () {
    //
    // },

    // update (dt) {},
});
